package org.nextive.android.weightapp.utils;

import java.text.DecimalFormat;

import org.nextive.android.weightapp.InitialSetup;
import org.nextive.android.weightapp.R;

import android.content.Context;
import android.content.SharedPreferences;

public class Utils 
{
	public static String getRoundedWeight(Context context, double weightValue)
	{
		SharedPreferences settings = context.getSharedPreferences(InitialSetup.PREFERENCES_NAME, 0);
        int unit = settings.getInt(InitialSetup.PREFERENCES_KEY_UNIT, 0);
        String[] units = context.getResources().getStringArray(R.array.units);
        if (units[unit].equals("Kilograms"))
		{
        	weightValue = weightValue*0.45359237;
		}
        DecimalFormat decimalFormat = new DecimalFormat("#.#");
		return decimalFormat.format(weightValue);
	}
}
